package org.yaac.shared.crud;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MetaNamespace implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String namespaceName;
	
	/**
	 * kinds name mapped with it's instance
	 */
	private Map<String, MetaKind> kindsMap;

	@SuppressWarnings("unused")
	private MetaNamespace(){}
	
	/**
	 * @param namespaceName
	 */
	public MetaNamespace(String namespaceName) {
		super();
		this.namespaceName = namespaceName;
		this.kindsMap = new HashMap<String, MetaKind>();
	}

	public String getNamespaceName() {
		return namespaceName;
	}

	public Map<String, MetaKind> getKindsMap() {
		return kindsMap;
	}

	public List<MetaKind> kindsList() {
		return new ArrayList<MetaKind>(this.kindsMap.values());
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((kindsMap == null) ? 0 : kindsMap.hashCode());
		result = prime * result + ((namespaceName == null) ? 0 : namespaceName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MetaNamespace other = (MetaNamespace) obj;
		if (kindsMap == null) {
			if (other.kindsMap != null)
				return false;
		} else if (!kindsMap.equals(other.kindsMap))
			return false;
		if (namespaceName == null) {
			if (other.namespaceName != null)
				return false;
		} else if (!namespaceName.equals(other.namespaceName))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "NamespaceInfo [namespaceName=" + namespaceName + ", kindsMap=" + kindsMap + "]";
	}
}
